<?php

namespace App\Domain\Dict\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Domain\Dict\Services\DictService;

class DictController extends Controller
{
    //字典列表
    public function configDict(Request $request, DictService $dictService)
    {
        $param = [
            'type_code' => $request['type_code']
        ];
        $res = $dictService->findByTypeCode($param);
        return $this->success($res);
    }

    //添加修改字典类型
    public function setDictType(Request $request, DictService $dictService)
    {
        $param = [
            'id' => $request['id'],
            'name' => $request['name'],
            'info' => $request['info'],
        ];
        $data = $dictService->setDictType($param);
        return $this->success($data);
    }


    //添加修改字典
    public function setDict(Request $request, DictService $dictService)
    {
        $param = [
            'id' => $request['id'],
            'name' => $request['name'],
            'info' => $request['info'],
            'type_code' => $request['type_code'],
            'code' => $request['code'],
        ];
        $data = $dictService->setDict($param);
        return $this->success($data);
    }
}
